package com.fac.controller.admin;

import com.fac.dto.PaymentAdminPageQueryDTO;
import com.fac.dto.PaymentRefundDTO;
import com.fac.result.PageResult;
import com.fac.result.Result;
import com.fac.service.PaymentRecordService;
import com.fac.vo.PaymentRefundVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 管理端支付Controller
 */
@RestController("adminPaymentController")
@RequestMapping("/admin/payments")
@Api(tags = "管理端-支付接口")
@Slf4j
public class PaymentController {

    @Autowired
    private PaymentRecordService paymentRecordService;

    /**
     * 查询支付记录
     */
    @GetMapping
    @ApiOperation("查询支付记录")
    public Result<PageResult> page(PaymentAdminPageQueryDTO queryDTO) {
        log.info("查询支付记录：{}", queryDTO);
        PageResult pageResult = paymentRecordService.adminPageQuery(queryDTO);
        return Result.success(pageResult);
    }

    /**
     * 退还押金
     */
    @PostMapping("/refund")
    @ApiOperation("退还押金")
    public Result<PaymentRefundVO> refund(@RequestBody PaymentRefundDTO refundDTO) {
        log.info("退还押金：{}", refundDTO);
        PaymentRefundVO vo = paymentRecordService.refund(refundDTO);
        return Result.success(vo);
    }
} 